package com.wbq501.wanandroid.model

import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope
import com.wbq501.common.base.BaseViewModel
import com.wbq501.net.entity.base.ApiPagerResponse
import com.wbq501.wanandroid.data.UserRepository
import kotlinx.coroutines.launch
import rxhttp.awaitResult

class OneViewModel : BaseViewModel(){
    private var pageIndex = 1

    var listData = MutableLiveData<ApiPagerResponse<Any>>()


    /**
     * 获取列表数据
     * @param isRefresh Boolean 是否是刷新
     * @param loadingXml Boolean 请求时是否需要展示界面加载中loading
     */
    fun getList(isRefresh: Boolean, loadingXml: Boolean = false){
        viewModelScope.launch {
            UserRepository.getList(1).awaitResult {
                listData.value = it
            }.onFailure {

            }
        }
    }
}